import 'package:flutter_benchu/utils/commonPkg.dart';

Widget appBarWidget(BuildContext context) {

  final options = [
    Option(
      text: text(context, Ids.homeGoPage),
      icon: IconFontDate(IconNameMap.huodongzhongxin),
      value: 1,
      onTap: (_) async {
        appRouter.navigateTo(context, Routes.cacheDemo);
      },
    ),
    Option(
      text: text(context, Ids.homeGoPage),
      icon: Icons.add_alert_rounded,
      value: 2,
      onTap: (_) async {
        appRouter.navigateTo(context, Routes.cacheDemo);
      },
    ),
    Option(
      text: text(context, Ids.homeGoPage),
      icon: Icons.disc_full_outlined,
      value: 2,
      onTap: (_) async {
        appRouter.navigateTo(context, Routes.cacheDemo);
      },
    ),
    Option(
      text: text(context, Ids.homeGoPage),
      icon: Icons.alarm_add_rounded,
      value: 2,
      onTap: (_) async {
        appRouter.navigateTo(context, Routes.cacheDemo);
      },
    ),

  ];

  return AppBar(
      centerTitle: true,
      title: Text('首页'),
      //左上角 我的入口
      leading: IconButton(
        padding: EdgeInsets.symmetric(horizontal: 0),
        icon: Icon(
          Icons.account_circle,
          size: 26.sp,
          color: Colors.white,
        ),
        onPressed: () {
          Scaffold.of(context).openDrawer(); //打开抽屉
          // Navigator.pop(context);            //关闭抽屉
        },
      ),
      actions: <Widget>[
        Container(
          child: IconButton(
            padding: EdgeInsets.only(right: 8.w),
            icon: Icon(
              IconFontDate(IconNameMap.saoyisao),
              size: 18.w,
              color: Colors.white,
            ),
            alignment: Alignment.centerRight,
            onPressed: () async {
              if (await checkPermission(PermissionGroup.camera)) {
                  String url = await appRouter.navTo(context,Routes.scannerDemo);
                  if(url.isEmpty) return;
                  showToast(url);
              }
            },
          ),
        ),
        Container(
          child: IconButton(
            padding: EdgeInsets.only(right: 16.w),
            alignment: Alignment.centerRight,
            icon: Icon(
              IconFontDate(IconNameMap.shouyexiwnen),
              size: 18.w,
              color: Colors.white,
            ),
            onPressed: () async {
              showDialog(
                context: context,
                // 这个组件位置是需要手动传入的  （重要）
                builder: (_) => Tooltips<int>(
                  options,
                  right: 14.w,
                  top: 57.w,
                )
              );
            },
          ),
        ),
      ]);
}